<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>入库单sql生成器</title>
		<script src="jquery-1.11.2.min.js"></script>
	</head>
	<body>
		<textarea id="text" cols="100" rows="20"></textarea>
		<input type="button" value="生成" onclick="makeSql()"/>
		<script>
			function makeSql() {
				var lines = $("#text").val().split(/[\r\n]/);
				var sqlArray = [];
				
				for (var i = 0; i < lines.length; i++) {
					var line = lines[i];
					var nums = line.split(/[\s\n]/);
					
//				sp.price AS '不含税单价',
//				sp.money AS '不含税总金额',
//				sp.taxrate AS '税率',
//				sp.tax_price AS '含税单价',
//				sp.tax_price_sum AS '总税额',
//				sp.price_total  AS '价税合计'
					
					var sql = "UPDATE t_storage_product SET "
					    	+ " price = " + nums[0] + ","
							+ " money = " + nums[1] + ","
							+ " taxrate = " + nums[2] + ","
							+ " tax_price = " + nums[3] + ","
							+ " tax_price_sum = " + nums[4] + ","
							+ " price_total = " + nums[5]
							+ " WHERE id = " + nums[6] 
							+ " LIMIT 1;";
					sqlArray.push(sql);
				}
				alert(sqlArray.join("\r\n"));
				console.log(sqlArray.join("\r\n"))
			}
			
		</script>
	</body>
</html>
